using GameFramework.Fsm;
using GameFramework.Procedure;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace LS.Procedure
{
    /// <summary>
    /// 启动流程，播放片头动画，显示资源更新界面，线上更新资源和数据的行为都在这里进行，没有的话就跳过流程直接切入下一个流程。
    /// </summary>
    public class ProcedureOpeningActions : ProcedureLoaderBase
    {
        private float m_Progress = 0;
        private bool m_IsFinish = false;

        public override float Progress => m_Progress;

        public override bool IsFinish => m_IsFinish;

        public override bool UseNativeDialog => false;

        private bool m_EnableOpeningAction = true;
        private float m_MainLoadingSeconds = 1f;

        protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
        {
            base.OnEnter(procedureOwner);
            bool useOpeningAction = LSEntry.Config.GetBool("OpeningAction.Enable",false);
            float loadingMainSeconds = LSEntry.Config.GetFloat("OpeningAction.LoadingMinSeconds", 1);

            this.m_EnableOpeningAction = useOpeningAction;
            this.m_MainLoadingSeconds = loadingMainSeconds;

            if (this.m_EnableOpeningAction)
            {
                //string openActionTexture = LSEntry.BuiltinData.AppConfigs.OpeningActions.OpenActionsTexturePath;
                //string openActionVideo = LSEntry.BuiltinData.AppConfigs.OpeningActions.OpenActionsVideoPath;

                //OpeningActionsParams oap = GameFramework.ReferencePool.Acquire<OpeningActionsParams>();
                //oap.OpeningActionsTexturePath = openActionTexture;
                //oap.OpeningActionsVideoPath = openActionVideo;

                //GameEntry.UI.OpenOpeningActions(oap);
            }

        }

        protected override void OnUpdate(IFsm<IProcedureManager> procedureOwner, float elapseSeconds, float realElapseSeconds)
        {
            base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
            if (!m_EnableOpeningAction)
            {
                ChangeNextProcedure(procedureOwner);
                return;
            }
        }

        protected void ChangeNextProcedure(IFsm<IProcedureManager> procedureOwner)
        {
            //this.Owner.SetData<DataParamsVariable<ProcedureDataLoadSceneParams>>(ProcedureDataLoadSceneParams.DataParamsKeyName, ProcedureDataLoadSceneParams.Create(null, GameEntry.Config.GetInt("Scene.Menu")));
            //this.ChangeState<ProcedureLoadScene>(this.Owner);
        }
    }
}
